<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>生意帮</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css" />
    <style>
        html,
        body {
            background-color: #fff;
        }
        #header_top .aui-icon-left,
        #header_top .aui-title,
        #header_top .aui-icon-search {
          color: #333;
        }
        .near_price {
            font-size: 1rem;
            color: #f23030;
        }


        .aui-list .aui-list-item-text.near_jj {
            height: 1rem;
            line-height: 1rem;
            overflow: hidden;
        }
    </style>
</head>

<body>

  <div id="app" v-cloak>
    <header class="aui-bar aui-bar-nav">
      <a class="aui-pull-left aui-btn" onclick="goback()">
          <span class="aui-iconfont aui-icon-left" style="color:#333" ></span>
      </a>
      <div class="aui-title">选择赠品</div>
      <a class="aui-pull-right aui-btn" onclick="cnm()">
          <span class="aui-iconfont aui-icon-search" style="color:#333" ></span>
      </a>
    </header>
    <ul class="aui-list aui-media-list">
        <li class="aui-list-item" @click="goExchangeDetail(item.goods_id)" v-for="item in info">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-media">
                    <div :style="'background: url('+item.logo_pic+') no-repeat center/cover;height: 4rem;width:100%'"></div>
                </div>
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title" style="">{{item.goods_name}}</div>
                        <!-- <div class="aui-list-item-right" v-if="item.type==3" style="color:#f23030;width:3rem">兑换商品</div> -->
                    </div>

                    <div class="aui-list-item-text near_jj">
                    {{item.goods_title}}
                    </div>
                    <div class="aui-info aui-margin-t-5" style="padding:0">
                        <div class="aui-info-item">
                            <span class="near_price">￥{{item.price}}</span>
                        </div>
                        <!-- <div class="aui-info-item">月销123笔</div> -->
                    </div>
                </div>
            </div>
        </li>
    </ul>
  </div>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>
<script type="text/javascript" src="../../script/aui-slide.js"></script>
<script type="text/javascript" src="../../script/aui-lazyload.js"></script>
<script type="text/javascript">
    function goback() {
        api.closeWin({
            name: 'exchangeMoreList'
        });
    }
    function cnm(){
      api.openWin({
          name: 'page1',
          url: '../two_frame/search_duihuan.html',
      });

    }
    apiready = function() {
    //  console.log(JSON.stringify(api))

      api.parseTapmode();
      var id = api.pageParam.goodsId;

      var app = new Vue({
        el: '#app',
        data: {
          info: [],

        },
        created: function() {
          var $_this = this;
          api.showProgress({
              title: '努力加载中...',
              text: '先喝杯茶...',
              modal: false
          });
          $_this.getExchangeList();


        },
        methods: {
          openShop: function(name, id) {
            api.openWin({
              name: 'shop_inner',
              url: '../two_frame/two_frame_header.html',
              pageParam: {
                  type: 'shop_inner',
                  name: name,
                  id: id
              }
            })
          },

          getExchangeList:function(cateid,keywords){
            console.log(JSON.stringify(api.pageParam.data))
            var $_this = this;
            api.ajax({
                url: window.Url.Freegoods_exchange,
                method: 'post',
                data: {
                    values: {
                        // token: $api.getStorage('token'),
                        goodsid:api.pageParam.goodsId,
                        longitude: $api.getStorage('longitude'),
                        latitude: $api.getStorage('latitude'),
                        give:api.pageParam.data,
                        cateid:cateid,
                        keywords:keywords
                    }
                }
            }, function(ret, err) {
                if (ret) {
                  console.log(JSON.stringify(ret))
                    if (ret.re != 2) {
                        $_this.info = ret.data.list
                        if(ret.data.list==""){
                          api.toast({
                              msg: '没有此商品',
                              duration: 1000,
                              location: 'middle'
                          });

                        }
                    }
                } else {
                    api.alert({
                        msg: JSON.stringify(err)
                    });
                }
            })
          },
          //赠品详情页
          goExchangeDetail:function(goodId){
            api.openWin({
              name: 'exchange',
              url: './commodity_exchange.html',
              pageParam: {
                exchangeId: goodId,
              }
            })
            setTimeout(function(){api.closeWin();},1000)
          }
        },
        mounted: function () {
          var $_this = this
          api.hideProgress();
          api.addEventListener({
              name: 'search_keywords'
          }, function(ret, err){
                $_this.getExchangeList('',ret.value.keywords);
                console.log(JSON.stringify(ret.value.keywords))          
          });

        }
      })
    }
</script>

</html>
